/* util */
import MsgModel from '@model/MsgModel'
import { ChatConversationParams, ChatInitParams } from '@model/param/in/AI'
import { ChatConversationResult, ChatInitResult } from '@model/param/out/AI'
import http from '@src/util/http'

function syncWiki(params: { tenantId: string, wikiTypeId: string }) {
  return http.post(`/language/wiki/sync`, params)
}

function deleteWiki(params: { ids: string[] }) {
  return http.post(`/language/wiki/delete`, params)
}

function updateWiki(params: { id: string }) {
  return http.post(`/language/wiki/update`, params)
}

function createWiki(params: { id: string }) {
  return http.post(`/language/wiki/create`, params)
}

function initChat(params: ChatInitParams): Promise<MsgModel<ChatInitResult>> {
  return http.post(`/language/chat/init`, params)
}

function conversationChat(params: ChatConversationParams): Promise<MsgModel<ChatConversationResult>> {
  return http.post(`/language/chat/conversation`, params, true, {
    cancelable: true
  })
}

export {
  syncWiki,
  deleteWiki,
  updateWiki,
  createWiki,
  initChat,
  conversationChat
}
